<%--                                                                       --%>
<%-- Copyright (c) 2001-2004 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>


<script language="JavaScript">
function validateEntries(theForm){
  if (theForm.maxFind.value == "") {
    alert('<bean:message key="cs.error.maximum.number.find"/>');
    return;
  } else {
    var num = parseInt(theForm.maxFind.value, 10);
    if (isNaN(num)) {
      alert('<bean:message key="cs.error.maximum.number.find.integer"/>');
      return;
    }
    if (num > 0) {
      theForm.maxFind.value = num;
    } else {
      alert('<bean:message key="cs.error.maximum.number.find.greater.than.zero"/>');
      return;
    }
  }
  theForm.submit();
  return;
}

function closeWindow() {
  self.close();
}

var checkflag = "false";
function check(field) {
  var SelectAllTxt = '<bean:message key="button.selectAll"/>';
  var UnselectAllTxt = '<bean:message key="button.unselectAll"/>';
 
  if(field == null) return SelectAllTxt;

  var max = field.length;

  if(max > 1) {
    if (checkflag == "false") {
      for (i = 0; i < max; i++) {
        field[i].checked = true;
      }
      checkflag = "true";
      return UnselectAllTxt;
    } else {
      for (i = 0; i < max; i++) {
        field[i].checked = false;
      }
      checkflag = "false";
      return SelectAllTxt;
    }
  } else {
    if (checkflag == "false") {
      field.checked = true;
      checkflag = "true";
      return UnselectAllTxt;
    } else {
      field.checked = false;
      checkflag = "false";
      return SelectAllTxt;
    }
  }
}

function refreshParentWindow(theForm, closeWindow) {
  var groupList = new Array;
  var index = 0; 
  if ( theForm.groupChkBox != null ) {
    var len = theForm.groupChkBox.length;
    if ( len > 1 ) {
      for ( var i=0; i<len; i++ ) {
        if ( theForm.groupChkBox[i].checked ) {
          groupList[index] = theForm.groupChkBox[i].value;
          index++;
        }
      }
    } else {
      if ( theForm.groupChkBox.checked ) {
        groupList[0] = theForm.groupChkBox.value;
      }
    }
    if ( groupList.length > 0 ) {
      window.opener.refreshGroupParticipants(groupList);
    } 
  }
  if ( closeWindow ) {
    self.close();
  } else {
    location='<html:rewrite page="/cs/microsite/participantFindGroup.do"/>';
  }
}

</script>

<html:form action="/cs/microsite/participantFindGroup.do">

<!-- Zone 5 starts here.  -->
      
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" 
       summary="content area">
  <tr>
    <td valign="top">
	
	<!-- close window button here -->
	  <div class="generalWrapRight">
        <html:button property="closeBtn" titleKey="button.close.window" styleClass="inputButton" onclick="javascript:closeWindow()">
          <bean:message key="button.close.window" />
        </html:button>
      </div>
	<!-- end button -->
	
    <!--start page title here-->
      <div class="app_pageTitle">
        <bean:message key="cs.find.more.group.participants"/>
      </div> 
    <!--end page title here-->
      
    <!-- start Page Instructions -->
    <div class="pageInstructions">
      <bean:message key="cs.participant.find.group.note.microsite"/>
    </div>
    <!-- End Page Instructions -->

    <!--start sub title bar here-->
    <div class="app_pageSubtitle">
      <span class="left">
        <bean:message key="cs.find"/>
      </span>
	  <span class="right">&nbsp;</span>
    </div>  
      
    <!--start main content area here-->
    <table class="labelForm" width="100%" border="0" cellspacing="0" 
           cellpadding="0" summary="Find participants Rules">
      <tr> 
        <td nowrap width="30%" class="label">
          <bean:message key="cs.group.name"/>:
        </td>
        <td width="70%" class="labelField" align=left>
          <html:text property="groupName" maxlength="30"/>
        </td>
      </tr>
      
      <tr>
        <td class="label"><bean:message key="cs.find.search.string"/>:</td>
        <td class="labelField" align=left>
          <html:radio property="searchPrefix" value="true"/>
          <bean:message key="cs.find.beginning.name"/>
        </td>
      </tr>
      
      <tr>
        <td class="label">&nbsp;</td>
        <td class="labelField" align=left>
          <html:radio property="searchPrefix" value="false"/>
          <bean:message key="cs.find.anywhere.name"/>
        </td>
      </tr>
      
      <tr>
        <td class="label"><bean:message key="cs.find.max.to.find"/>:</td>
        <td class="labelField" align=left>
          <html:text property="maxFind" maxlength="4" size="4"/>
        </td>
      </tr>
                  
    </table>
    <div class="pageButtonWrap" align="right">  
      <html:button property="showResultBtn" titleKey="button.show.results" styleClass="pageButton" onclick="javascript:validateEntries(this.form)">
        <bean:message key="button.show.results" />
      </html:button>
    </div>  
    
	<br>     

  <c:if test="${csParticipantFindGroupForm.map.findParticipants}">
    <!--start sub title bar here-->
    <div class="app_pageSubtitle">
      <span class="left">
        <bean:message key="cs.participants"/>
      </span>
    </div>  
    
    <div class="globalButtonWrap">
      <input type="button" name="selectAll" class="globalButton"
             onclick="this.value=check(this.form.groupChkBox)" 
             value="<bean:message key='button.selectAll'/>"> 
    </div>
          
    <!-- Start List here -->
    <table class="dataTable" border="0" cellspacing="1" cellpadding="2" 
           summary="Search result table" width="100%">
      
      <c:if test="${empty participantFindGroupView.map.groupList}">
        <tr class="listOdd">
          <td align="center" colspan=3><bean:message key="cs.find.zero.item"/>
          </td>
        </tr>
      </c:if>
      <c:if test="${!empty participantFindGroupView.map.groupList}">
        <tr class="listHeader"> 
          <th id="select" align="center"><bean:message key="cs.select"/></th>
          <th id="name" align="left"><bean:message key="cs.group.name"/></th>
        </tr>
               
        <c:forEach var="oneGroup" items="${participantFindGroupView.map.groupList}" varStatus="index">
        
        <c:if test="${index.count%2 == 0}">
          <c:set var="classVar" value="listEven" scope="page" />
        </c:if>
        <c:if test="${index.count%2 != 0}">
           <c:set var="classVar" value="listOdd" scope="page" />
        </c:if>
       
          <tr class='<c:out value="${classVar}"/>'> 
            <td headers="select" align="center">
              <c:if test="${oneGroup.map.participant}">
                <html:img page="/cs/images/icons/cicon_checkmark.gif" alt=""/>
              </c:if>
              <c:if test="${! oneGroup.map.participant}">
                  <input type="checkbox" name="groupChkBox" 
                         value='<c:out value="${oneGroup.map.fullName}" />' >
              </c:if>
            </td>
            <td headers="name" align="left">
              <c:out value="${oneGroup.map.fullName}"/>
            </td>
          </tr>
        </c:forEach>
      </c:if> 
    </table>
    <!--start cancel, reset, save bar area here-->
  
    <div class="pageButtonWrap" align="right">
      <html:button property="cancelBtn" titleKey="button.cancel" styleClass="pageButton" onclick="javascript:closeWindow()">
         <bean:message key="button.cancel" />
      </html:button>
      <c:if test="${participantFindGroupView.map.hasCandidate}">
        <html:button titleKey="cs.find.add.continue" property="addContinueBtn" onclick="refreshParentWindow(this.form,false)" styleClass="pageButton">
          <bean:message key="cs.find.add.continue" />
        </html:button> 
        <html:button titleKey="cs.find.add.done" property="addDoneBtn" onclick="refreshParentWindow(this.form, true)" styleClass="pageButton">
          <bean:message key="cs.find.add.done" />
        </html:button> 
      </c:if>
    </div>     
    </c:if><%-- end of csParticipantFindGroupForm.findParticipants == true. --%>

      </td>
    </tr>
  </table> 
  <input type=hidden name="findParticipants" value="true"/>
</html:form>
  

